#!/bin/bash

# 查找所有Streamlit相关进程，排除8501端口，获取PID并终止
for pid in $(ps aux | grep 'streamlit' | grep -v grep | awk '{print $2}'); do
    # 检查当前进程是否使用8501端口
    if ! lsof -i :8501 | grep -q $pid; then
        echo "终止Streamlit进程 $pid (非8501端口)"
        kill -9 $pid
    else
        echo "保留Streamlit进程 $pid (8501端口)"
    fi
done